import request from "../utils/request";
import qs from "qs";

/**
 * 获取项目名称
 */
export function getProjectName() {
  return request({
    url: "/main/getProjectName",
    method: "POST",
  });
}

/**
 * 登录
 */
export function login(data) {
  return request({
    url: "/main/login",
    method: "POST",
    data: qs.stringify(data),
  });
}

/**
 * 退出
 */

export function logout() {
  return request({
    url: "/main/logout",
    method: "POST",
  });
}
/**
 * 获取登录用户信息
 */
export function loginInfo(data) {
  return request({
    url: "/main/current",
    method: "POST",
    headers: {
      "X-Skip-Code-Check": "true",
    },
    data: qs.stringify(data),
  });
}

/**
 * 获取路由信息
 */
export function getReportMenu(data) {
  return request({
    url: "/menu/getReportMenu",
    method: "POST",
    data: qs.stringify(data),
  });
}

/**
 * 获取权限
 */
export function getBtnPermission() {
  return request({
    url: "/menu/getBtnPermission",
    method: "POST",
    headers: {
      "X-Skip-Code-Check": "true",
    },
  });
}

/**
 * 路由菜单列表
 */
export function menuTreeList() {
  return request({
    url: "/menu/getSysTree",
    method: "POST",
  });
}

/**
 * 表单管理
 */
export function queryPage(params, data) {
  return request({
    url: `/${params}/queryPage`,
    method: "POST",
    headers: {
      "X-Skip-Code-Check": "true",
    },
    data: data,
  });
}

/**
 * 数据类型
 */
export function sysDict(data) {
  return request({
    url: "/dict/getEntityWithRelationsByField",
    method: "POST",
    data: qs.stringify(data),
  });
}
/**
 * 继承类-数据
 */
export function getBaseField(data) {
  return request({
    url: "/form/getBaseField",
    method: "POST",
    data: qs.stringify(data),
  });
}

/**
 * 校验表单
 */
export function checkOnly(params,data) {
  return request({
    url: `/${params}/checkOnly`,
    method: "POST",
    headers: {
      "X-Skip-Code-Check": "true",
    },
    data: qs.stringify(data),
  });
}

/**
 * 保存表单
 */
export function formAdd(data) {
  return request({
    url: "/form/saveForm",
    method: "POST",
    data: data,
  });
}
/**
 * 获取form详情
 */
export function getFormDetail(data) {
  return request({
    url: "/form/getEntityWithRelationsById",
    method: "POST",
    data: qs.stringify(data),
  });
}
/**
 * 保存菜单
 */
export function menuAdd(data) {
  return request({
    url: "/menu/saveTreeEntity",
    method: "POST",
    headers: {
      "X-Skip-Code-Check": "true",
    },
    data: data,
  });
}

/**
 *  保存接口
 */
export function saveTreeEntity(params, data) {
  return request({
    url: `/${params}/saveTreeEntity`,
    method: "POST",
    headers: {
      "X-Skip-Code-Check": "true",
    },
    data: data,
  });
}

/**
 * 删除接口
 */
export function delEntityById(params, data) {
  return request({
    url: `/${params}/delEntityById`,
    method: "POST",
    headers: {
      "X-Skip-Code-Check": "true",
    },
    data: qs.stringify(data),
  });
}
/**
 * 菜单隐藏和显示
 */
export function menuHidden(data) {
  return request({
    url: "/menu/hideOrShowMenuMenu",
    method: "POST",
    headers: {
      "X-Skip-Code-Check": "true",
    },
    data: qs.stringify(data),
  });
}
/**
 * 详情数据
 */

export function getDetailId(params, data) {
  return request({
    url: `/${params}/getEntityById`,
    method: "POST",
    data: qs.stringify(data),
  });
}

/**
 * 行详情数据
 */

export function getRowById(params, data) {
  return request({
    url: `/${params}/getRowById`,
    method: "POST",
    data: qs.stringify(data),
  });
}
/**
 * 树形结构
 */
export function queryTreeList(params, data) {
  return request({
    url: `${params}/queryTreeList`,
    method: "POST",
    data: qs.stringify(data),
  });
}

/**
 * 菜单树结构
 */
export function getMenuTree(params) {
  return request({
    url: "/menu/getMenuTree",
    method: "POST",
    data: qs.stringify(params),
  });
}

/**
 * 结构列表
 */
export function queryList(params, data) {
  return request({
    url: `/${params}/queryList`,
    method: "POST",
    data: data,
  });
}

/**
 * 用户管理数据
 */
export function getUserTree() {
  return request({
    url: "/dept/getTree",
    method: "POST",
  });
}

/**
 * 权限保存
 */
export function saveRoleMenu(params) {
  return request({
    url: "/role/saveRoleMenu",
    method: "POST",
    data: qs.stringify(params),
    headers: {
      "X-Skip-Code-Check": "true",
    },
  });
}

/**
 * 生产进度报表
 */
export function getProductProgressData(data) {
  return request({
    url: "/report/yjjProductionProgress",
    method: "POST",
    data: qs.stringify(data),
  });
}

/**
 * 质量报表
 */
export function getQualityData(data) {
  return request({
    url: "/report/findQualityControllerVO",
    method: "POST",
    data: qs.stringify(data),
  });
}

/**
 * 根据code获取当前页面的信息
 * form/initFieldData
 */
export function initFieldData(data) {
  return request({
    url: "/form/initFieldData",
    method: "POST",
    data: qs.stringify(data),
  });
}

/**
 * 获取表格数据
 */
export function getQueryMapPage(param, data) {
  return request({
    url: `${param}/queryMapPage`,
    method: "POST",
    data: data,
    headers: {
      "X-Skip-Code-Check": "true",
    },
  });
}

/**
 * 获取设备表格数据
 */
export function getQueryRowPage(param, data) {
  return request({
    url: `${param}/queryRowPage`,
    method: "POST",
    data: data,
    headers: {
      "X-Skip-Code-Check": "true",
    },
  });
}

/**
 * 订阅消息
 */
export function getMsgTemplatesByUserId(data) {
  return request({
    url: "msgTemplate/getMsgTemplatesByUserId",
    method: "POST",
    data: qs.stringify(data),
  });
}

/**
 * 设置角色
 */
export function getRolesByUserId() {
  return request({
    url: "role/getRolesByUserId",
    method: "POST",
  });
}

/**
 * 新增/编辑保存
 */
export function saveEntity(param, data) {
  return request({
    url: `${param}/saveEntity`,
    method: "POST",
    data: data,
    headers: {
      "X-Skip-Code-Check": "true",
    },
  });
}
